package com.scvtc.controller.teacher;

import com.scvtc.domain.ResResult;
import com.scvtc.domain.dto.teacher.base.TeacherBaseDto;
import com.scvtc.domain.vo.PageVo;
import com.scvtc.service.teacher.TeacherBaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 教师基本信息(TeacherBase)表控制层
 *
 * @author thy
 * @since 2022-04-13 17:38:29
 */
@Api(tags = "教师基本信息(TeacherBase)")
@RestController
@RequestMapping("teacherBase")
public class TeacherBaseController {
    /**
     * 教师基本信息(TeacherBase)对象
     */
    @Autowired
    private TeacherBaseService teacherBaseService;


    @GetMapping("/list")
    @ApiOperation("查询教师信息")
    public ResResult<PageVo<List<TeacherBaseDto>>> getAllTeacher(
            @RequestParam(defaultValue = "1") Long current,
            @RequestParam(defaultValue = "10") Long size,
            TeacherBaseDto teacherBaseDto) {
        return teacherBaseService.getAllTeacher(current, size, teacherBaseDto);
    }

    @DeleteMapping("/")
    @ApiOperation("删除一条教师信息")
    public ResResult<?> deleteTeacher(Long id) {
        return teacherBaseService.deleteTeacherBase(id);
    }

    @DeleteMapping("/multiple")
    @ApiOperation("删除多条教师信息")
    public ResResult<?> deleteMultipleTeacherBase(Long[] ids) {
        return teacherBaseService.deleteMultipleTeacherBase(ids);
    }

    @PostMapping("/")
    @ApiOperation("添加单个教师")
    public ResResult<?> addTeacherBase(@RequestBody TeacherBaseDto teacherBaseDto) {
        return teacherBaseService.addTeacherBase(teacherBaseDto);
    }

    @PutMapping("/")
    @ApiOperation("修改单个教师")
    public ResResult<?> updateStudentBase(@RequestBody TeacherBaseDto teacherBaseDto) {
        return teacherBaseService.updateTeacherBase(teacherBaseDto);
    }
//
//    @GetMapping(value = "/export", produces = "application/octet-stream")
//    @ApiOperation("导出excel")
//    public void exportExcel(
//            HttpServletResponse response,
//            TeacherBaseDto teacherBaseDto
//    ) {
//        teacherBaseService.exportExcel(response, teacherBaseDto);
//    }

    @GetMapping(value = "/export", produces = "application/octet-stream")
    @ApiOperation("导出excel")
    public void exportExcel(
            HttpServletResponse response,
            Long[] ids
    ) {
        teacherBaseService.exportExcel(response, ids);
    }

    @GetMapping(value = "/chart/degree")
    @ApiOperation("教师等级（charts 图）")
    public ResResult<?> chartDegree() {
        return teacherBaseService.chartDegree();
    }
}

